<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
	<!-- 导入jquery核心类库 -->
	<script type="text/javascript"
			src="${pageContext.request.contextPath }/js/jquery-1.8.3.js"></script>
	<!-- 导入easyui类库 -->
	<link rel="stylesheet" type="text/css"
		  href="${pageContext.request.contextPath }/js/easyui/themes/default/easyui.css">
	<link rel="stylesheet" type="text/css"
		  href="${pageContext.request.contextPath }/js/easyui/themes/icon.css">
	<link rel="stylesheet" type="text/css"
		  href="${pageContext.request.contextPath }/js/easyui/ext/portal.css">
	<link rel="stylesheet" type="text/css"
		  href="${pageContext.request.contextPath }/css/default.css">
	<script type="text/javascript"
			src="${pageContext.request.contextPath }/js/easyui/jquery.easyui.min.js"></script>
	<script type="text/javascript"
			src="${pageContext.request.contextPath }/js/easyui/ext/jquery.portal.js"></script>
	<script type="text/javascript"
			src="${pageContext.request.contextPath }/js/easyui/ext/jquery.cookie.js"></script>
	<script
			src="${pageContext.request.contextPath }/js/easyui/locale/easyui-lang-zh_CN.js"
			type="text/javascript"></script>
	<script type="text/javascript" src="${pageContext.request.contextPath }/js/jquery.ocupload-1.1.2.js"></script>
</head>
<body class="easyui-layout" style="visibility:hidden;">
    <div region="center" border="false">
    	<table id="grid"></table>
	</div>


	<script type="text/javascript">
		// 工具栏
		var toolbar = [ {
			id : 'button-view',
			text : '查看',
			iconCls : 'icon-search',
			handler : doView
		}, {
			id : 'button-add',
			text : '新增',
			iconCls : 'icon-add',
			handler : doAdd
		}, {
			id : 'button-delete',
			text : '删除',
			iconCls : 'icon-cancel',
			handler : doDelete
		}];
		//定义冻结列
		var frozenColumns = [ [ {
			field : 'id',
			checkbox : true,
			rowspan : 2
		}, {
			field : 'username',
			title : '名称',
			width : 80,
			rowspan : 2
		} ] ];


		// 定义标题栏
		var columns = [ [
			{
				field : 'ids',
				title : 'id',
				width : 60,
				checkbox:true,
				rowspan : 2,
				align : 'center',
				formatter:function (data, row, index) {
					return row.id
				}
			},
			{
				field : 'id',
				title : 'id',
				width : 300,
				rowspan : 2,
				align : 'center'
			},{
			field : 'username',
			title : '姓名',
			width : 120,
			rowspan : 2,
			align : 'center'
		},{
				field : 'password',
				title : '密码',
				width : 120,
				rowspan : 2,
				align : 'center'
			},{
			field : 'gender',
			title : '性别',
			width : 60,
			rowspan : 2,
			align : 'center'
		}, {
			field : 'birthday',
			title : '生日',
			width : 120,
			rowspan : 2,
			align : 'center'
		}, {
			title : '其他信息',
			colspan : 2
		}, {
			field : 'telephone',
			title : '电话',
			width : 800,
			rowspan : 2
		} ], [ {
			field : 'station',
			title : '单位',
			width : 80,
			align : 'center'
		}, {
			field : 'salary',
			title : '工资',
			width : 80,
			align : 'right'
		} ] ];
		$(function(){


			$("body").css({visibility:"visible"});


			// 收派标准数据表格
			$('#grid').datagrid( {
				iconCls : 'icon-forward',
				fit : true,
				border : false,
				rownumbers : true,
				striped : true,
				pageList: [10,20,50,100],
				pagination : true,
				toolbar : toolbar,
				url : "${pageContext.request.contextPath }/user/findPage.action",
				idField : 'id',
				columns : columns,
				onDblClickRow : doDblClickRow,
				onClickRow : onClickRow
			});






		});
		// 双击
		function doDblClickRow(rowIndex, rowData) {
			var items = $('#grid').datagrid('selectRow',rowIndex);
			doView();
		}
		// 单击
		function onClickRow(rowIndex){

		}

		function doAdd() {

			location.href="${pageContext.request.contextPath}/page/admin/userinfo.action";
		}

		function doView() {
			alert("编辑用户");
			var item = $('#grid').datagrid('getSelected');
			console.info(item);
			//window.location.href = "edit.html";
		}

		function doDelete() {
			alert("删除用户");
			var ids = [];
			var items = $('#grid').datagrid('getSelections');
			for(var i=0; i<items.length; i++){
				ids.push(items[i].id);
			}

			console.info(ids.join(","));

			$('#grid').datagrid('reload');
			$('#grid').datagrid('uncheckAll');
		}

	</script>
</body>



</html>